package com.kefu.admin.modules.tgqmdj.service.impl;

import com.kefu.admin.modules.sys.model.AreaModel;
import com.kefu.admin.modules.tgqmdj.mapper.TgShhMapper;
import com.kefu.admin.modules.tgqmdj.mapper.TgdMapper;
import com.kefu.admin.modules.tgqmdj.mapper.TgdSpszMapper;
import com.kefu.admin.modules.tgqmdj.model.Article;
import com.kefu.admin.modules.tgqmdj.model.TgCommtable;
import com.kefu.admin.modules.tgqmdj.model.TgShEntity;
import com.kefu.admin.modules.tgqmdj.model.Tgctms;
import com.kefu.admin.modules.tgqmdj.service.TgdService;
import com.kefu.admin.utils.CechData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by TWD on 2018/10/17.
 */
@Service
public class TgdServiceImpl implements TgdService {

    @Autowired
    private TgdMapper tgdMapper;

    @Autowired
    private TgdSpszMapper tgdSpszMapper;

    @Autowired
    private TgShhMapper tgShhMapper;


    @Override
    public List<TgCommtable> querycommtable() {
        return tgdSpszMapper.querycommtable();
    }

    @Override
    public void initCommtable() {
        List<TgCommtable> querycommtableList = tgdSpszMapper.querycommtable();
        CechData.setCommkey(querycommtableList);
    }


    @Override
    public List<TgShEntity> queryAllShhList(TgShEntity tgShEntity) {
        return tgShhMapper.queryShhList(tgShEntity);
    }

    @Override
    public List<TgShEntity> queryPidShhList(Long pid,String wordhh) {
        TgShEntity tgShEntity = new TgShEntity();
        tgShEntity.setPid(pid);
        tgShEntity.setShh(wordhh);
        if(tgShEntity.getPid().longValue()==0){
            tgShEntity.setPid(null);
            return tgShhMapper.queryPidShhListWord(tgShEntity);
        }
        return tgShhMapper.queryPidShhList(tgShEntity);
    }

    @Override
    public int updateShhInfo(TgShEntity tgShEntity) {
        return tgShhMapper.updateShhInfo(tgShEntity);
    }

    @Override
    public List<AreaModel> queryAreaList(Map<String, Object> params) {
        return tgdMapper.queryAreaList(params);
    }

    @Override
    public List<Tgctms> queryCtMsg(Map<String, Object> params) {
        return tgdMapper.queryCtMsg(params);
    }
    

    @Override
    public int saveCtMsg(Tgctms tgctms) {
        return tgdMapper.saveCtMsg(tgctms);
    }

	@Override
	public List<Tgctms> queryCtMsg(Tgctms Tgctms) {
		// TODO Auto-generated method stub
		return tgdMapper.queryCtMsg(Tgctms);
	}

    @Override
    public int saveMyCtMsg(Tgctms tgctms) {
        return tgdMapper.saveMyCtMsg(tgctms);
    }

    @Override
    public List<Tgctms> queryMyCtMsg(Tgctms Tgctms) {
        // TODO Auto-generated method stub
        return tgdMapper.queryMyCtMsg(Tgctms);
    }

    @Override
    public List<Tgctms> queryMyCtMsgImg(Tgctms Tgctms) {
        // TODO Auto-generated method stub
        return tgdMapper.queryMyCtMsgImg(Tgctms);
    }

	@Override
	public int updStatus(Tgctms tgctms) {
		// TODO Auto-generated method stub
		return tgdMapper.updStatus(tgctms);
	}

	@Override
	public int updateStatusBatch(List<String> ids, int hideflag) {
		Map<String,Object> params = new HashMap<String,Object>(2);
        params.put("ids",ids);
        params.put("hideflag",hideflag);
		return tgdMapper.updateStatusBatch(params);
	}
}
